package com.online.controller;

import com.online.entity.ApiResult;
import com.online.entity.JudgeQuestion;
import com.online.service.JudgeQuestionService;
import com.online.util.ApiResultHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 判断题
 */
@RestController
public class JudgeQuestionController {
    @Autowired
    private JudgeQuestionService judgeQuestionService;

    @PostMapping("/judgeQuestion")
    public ApiResult add(@RequestBody JudgeQuestion judgeQuestion){
        int res=judgeQuestionService.add(judgeQuestion);
        if (res!=0){
            return ApiResultHandler.buildApiResult(200,"添加成功",res);
        }else{
            return ApiResultHandler.buildApiResult(400,"添加失败",res);
        }
    }
    @GetMapping("/judgeQuestionId")
    public ApiResult findOnlyQuestionId(){
        JudgeQuestion res = judgeQuestionService.findOnlyQuestionId();
        return  ApiResultHandler.buildApiResult(200,"查询成功",res);
    }
}
